package weeek11.topic06;

import io.lettuce.core.RedisClient;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.api.reactive.RedisReactiveCommands;
import io.lettuce.core.api.sync.RedisCommands;
import io.lettuce.core.api.sync.RedisStringCommands;
import reactor.core.publisher.Mono;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;

/**
 * @author lfy
 */
public class LettuceTest {
    public static void main(String[] args) {
        RedisClient client = RedisClient.create("redis://localhost");
        StatefulRedisConnection<String, String> connect = client.connect();

        RedisCommands<String, String> sync = connect.sync();
        //String类型的操作
        sync.set("key","value");
        String value = sync.get("key");
        System.out.println("String read:"+value);
        //list类型的操作

        sync.lpush("list_key","list_v1","list_v2");
        sync.lpush("list_key","list_v1","list_v2");

        while (sync.llen("list_key")>0){
           String val = sync.rpop("list_key");
           System.out.println("list read:"+val);
       }


       //zset 类型操作
        sync.zadd("zset_key",1,"zset_1");
        sync.zadd("zset_key",2,"zset_2");
        sync.zadd("zset_key",3,"zset_3");

        List<String> zset = sync.zrange("zset_key", 0, 5);
        System.out.println(zset);


    }


}
